class Solution:
    def countBits(self, num: int) -> List[int]:
        result=[0]*(num+1)
        hi=0
        for i in range(1,num+1):
            if i&(i-1)==0:
                result[i]=1
                hi=i
            else:
                result[i]=result[i-hi]+1
        return result